package foguing.test;

import static org.junit.Assert.assertEquals;

import org.apache.uima.collection.CollectionReaderDescription;
import org.apache.uima.fit.factory.CollectionReaderFactory;
import org.apache.uima.fit.pipeline.JCasIterable;
import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.JCas;
import org.junit.Test;

import com.unidue.foguing.task_A.Reader_TaskA;
import com.unidue.foguing.types.*;

public class ReaderTestTask_A {
	@Test
	public void test() throws Exception{
		CollectionReaderDescription reader = CollectionReaderFactory.createReaderDescription(
                Reader_TaskA.class,
                Reader_TaskA.INPUT_FILE, "src/test/resources/test/myTestTask_A.txt");
		
		int i = 0;
		for(JCas jCas : new JCasIterable(reader)){
			// we just no that the third line is objective , so test it !!!!!
			if(i == 2){
				// since we have added the whole sentence to the jcas documentText, just check whether the both match together or not
				assertEquals("Theo Walcott is still shit, watch Rafa and Johnny deal with him on Saturday.", jCas.getDocumentText());
				ActualSentiment actualSentiment = JCasUtil.selectSingle(jCas, ActualSentiment.class);
				assertEquals("objective" , actualSentiment.getActualSentiment());
			}
			
			System.out.println(jCas.getDocumentText());
			i++;
		}
		// there are 9 lines in the files.
		assertEquals(9,i);
	}
}
